<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<link th:href="@{/mayioa/css/mayioa-ui.css}" rel="stylesheet"/>
<link th:href="@{/ajax/libs/datapicker/datepicker3.css}" rel="stylesheet"/>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-user-add">
        <input name="deptId" type="hidden" id="treeId"/>


        <div class="form-group">
            <label class="col-sm-3 control-label ">员工工号：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" id="idCode" name="idCode" placeholder="6位员工工号" minlength="6"
                       maxlength="6"/>
            </div>
        </div>


        <div class="form-group">
            <label class="col-sm-3 control-label ">姓名：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" id="name" name="name"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">性別：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" id="sex" name="sex"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">电话号码：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="phone" id="phone" placeholder="11位手机号码" minlength="11"
                       maxlength="11">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">邮箱：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="email" id="email">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">地址：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="address" id="address">
            </div>
        </div>


        <div class="form-group">
            <label class="col-sm-3 control-label">入职日期：</label>
            <div class="col-sm-8">
                <input class="form-control" type="date" name="joinDate" id="joinDate">
            </div>
        </div>


        <div class="form-group">
            <label class="col-sm-3 control-label">状态：</label>
            <div class="col-sm-8">
                <select class="form-control" type="text" name="status" id="status">
                    <option value="在职">在职</option>
                    <option value="离职">离职</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">地域：</label>
            <div class="col-sm-8">
                <select class="form-control" type="text" name="region" id="region">
                    <option value="西安">西安</option>
                    <option value="北京">北京</option>
                    <option value="深圳">深圳</option>
                    <option value="成都">成都</option>
                    <option value="天津">天津</option>
                    <option value="上海">上海</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">技能：</label>
            <div class="col-sm-8">
                <select class="form-control" type="text" name="skillType" id="skillType">
                    <option value="java">java</option>
                    <option value="android">android</option>
                    <option value="c++">c++</option>
                    <option value="python">python</option>
                </select>

            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">级别：</label>
            <div class="col-sm-8">
                <select class="form-control" type="text" name="level" id="level">
                    <option value="高级工程师">高级工程师</option>
                    <option value="中级工程师">中级工程师</option>
                    <option value="初级工程师">初级工程师</option>
                    <option value="实习工程师">实习工程师</option>
                </select>

            </div>
        </div>


    </form>
</div>
<div th:include="include::footer"></div>
<script th:src="@{/ajax/libs/select/select2.js}"></script>
<script th:src="@{/js/jquery-ui-1.10.4.min.js}"></script>
<script th:src="@{/ajax/libs/iCheck/icheck.min.js}"></script>
<script th:src="@{/ajax/libs//datapicker/bootstrap-datepicker.js}"></script>
<script th:src="@{/ajax/libs/beautifyhtml/beautifyhtml.js}"></script>
<script>

    $("#form-staffmanager-edit").validate({
        rules: {
            idCode: {
                required: true
            },

            name: {
                required: true
            },
            sex: {
                required: true
            },
            phone: {
                required: true
            },
            email: {
                required: true
            },
            address: {
                required: true
            }
        },
        messages: {
            "name": {
                remote: "姓名不能为空"
            }
        },
        submitHandler: function (form) {
            submitHandler();
        }
    });

    function submitHandler() {
        if ($.validate.form()) {
            add();
        }
    }

    function add() {
        var idCode = $("input[name='idCode']").val();
        var name = $("input[name='name']").val();
        var sex = $("input[name='sex']").val();
        var phone = $("input[name='phone']").val();
        var email = $("input[name='email']").val();
        var address = $("input[name='address']").val();
        var joinDate = $("input[name='joinDate']").val();
        var status = $("#status option:selected").val();
        var region = $("#region option:selected").val();
        var skillType = $("#skillType option:selected").val();
        var level = $("#level option:selected").val();
        $.ajax({
            cache: true,
            type: "POST",
            url: ctx + "staffmanager/list/manageradd",
            data: {
                "idCode": idCode,
                "name": name,
                "sex": sex,
                "phone": phone,
                "email": email,
                "address": address,
                "joinDate": joinDate,
                "status": status,
                "region": region,
                "level": level,
                "skillType": skillType
            },
            async: false,
            error: function (request) {
                $.modal.alertError("系统错误");
            },
            success: function (data) {
                $.operate.saveSuccess(data);
            }
        });
    }

    /*
        /!*用户管理-新增-选择部门树*!/
        function selectDeptTree() {
            var treeId = $("#treeId").val();
            var deptId = $.common.isEmpty(treeId) ? "100" : $("#treeId").val();
            var url = ctx + "system/dept/selectDeptTree/" + deptId;
            var options = {
                title: '选择部门',
                width: "380",
                url: ctx + "system/dept/selectDeptTree/" + deptId,
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }

        function doSubmit(index, layero) {
            var tree = layero.find("iframe")[0].contentWindow.$._tree;
            if ($.tree.notAllowParents(tree)) {
                var body = layer.getChildFrame('body', index);
                $("#treeId").val(body.find('#treeId').val());
                $("#treeName").val(body.find('#treeName').val());
                layer.close(index);
            }
        }*/

</script>
</body>
</html>
